package com.situ.day4;

import org.junit.Test;

public class OOPDemo {
    @Test
    public void test1() {
        //4、类是对象的模板，对象是类的具体实例。
        //5、一个类可以创建多个对象：同一个类的不同对象，结构相同，数据不同。
        //student1:变量、引用(存地址值)、对象(实例)
        Student student1 = new Student();
        student1.id = 1;
        student1.name = "王五";
        student1.age = 23;
        student1.gender = "男";
        student1.study();

        Student student2 = new Student();
        student2.id = 2;
        student2.name = "张三";
        student2.age = 24;
        student2.gender = "女";
        student2.study();
        //flag  isSuShu
    }

    @Test
    public void test2() {
        Student student = new Student();
        System.out.println(student.id);//0
        System.out.println(student.name);//null
        //System.out.println(student.ok);//false
    }

    @Test
    public void test3() {
        int[] array1 = new int[3];
        boolean[] array2 = new boolean[3];

        Student[] students = new Student[3];
        for (int i = 0; i < students.length; i++) {
            System.out.println(students[i]);
        }
        //增强的for循环
        for (Student student : students) {
            System.out.println(student);
        }
    }

    @Test
    public void test4() {
        //NullPointerException空指针异常（引用数据类型）
        Student student = null;
        System.out.println(student);//null
        // null.方法   null.属性
        System.out.println(student.id);
    }

    @Test
    public void test44() {
        Student student = new Student();
        student.id = 1;
        student.name = "王五";
        student.age = 223;
        student.gender = "男";
        String info = student.getInfo();
        System.out.println(info);
        System.out.println(student.getInfo());
        System.out.println("-----------");
        //com.situ.day4.Student@22927a81
        System.out.println(student);
        System.out.println(student.toString());
    }
}
